]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/server_test.go
Fix tracker results
[rbdr/mobius] / hotline / server_test.go
index 0487d2e586a650b7e268138f99f86491586767a4..d0e2372a9d4d8e9cd83afbfc1acf9995a4ea4268 100644 (file)
@@ -99,21 +99,20 @@ func TestServer_handleFileTransfer(t *testing.T) {
                {
                        name: "file download",
                        fields: fields{
-                               FS: &OSFileStore{},
-                               Config: Config{
-                                       FileRoot: func() string {
-                                               path, _ := os.Getwd()
-                                               return path + "/test/config/Files"
-                                       }()},
+                               FS:     &OSFileStore{},
                                Logger: NewTestLogger(),
                                Stats:  NewStats(),
                                FileTransferMgr: &MemFileTransferMgr{
                                        fileTransfers: map[FileTransferID]*FileTransfer{
                                                {0, 0, 0, 5}: {
-                                                       refNum:   [4]byte{0, 0, 0, 5},
+                                                       RefNum:   [4]byte{0, 0, 0, 5},
                                                        Type:     FileDownload,
                                                        FileName: []byte("testfile-8b"),
                                                        FilePath: []byte{},
+                                                       FileRoot: func() string {
+                                                               path, _ := os.Getwd()
+                                                               return path + "/test/config/Files"
+                                                       }(),
                                                        ClientConn: &ClientConn{
                                                                Account: &Account{
                                                                        Login: "foo",
@@ -171,7 +170,6 @@ func TestServer_handleFileTransfer(t *testing.T) {
                        s := &Server{
                                FileTransferMgr: tt.fields.FileTransferMgr,
                                Config:          tt.fields.Config,
-                               ConfigDir:       tt.fields.ConfigDir,
                                Logger:          tt.fields.Logger,
                                Stats:           tt.fields.Stats,
                                FS:              tt.fields.FS,
@@ -183,61 +181,3 @@ func TestServer_handleFileTransfer(t *testing.T) {
                })
        }
 }
-
-type TestData struct {
-       Name  string `yaml:"name"`
-       Value int    `yaml:"value"`
-}
-
-func TestLoadFromYAMLFile(t *testing.T) {
-       tests := []struct {
-               name     string
-               fileName string
-               content  string
-               wantData TestData
-               wantErr  bool
-       }{
-               {
-                       name:     "Valid YAML file",
-                       fileName: "valid.yaml",
-                       content:  "name: Test\nvalue: 123\n",
-                       wantData: TestData{Name: "Test", Value: 123},
-                       wantErr:  false,
-               },
-               {
-                       name:     "File not found",
-                       fileName: "nonexistent.yaml",
-                       content:  "",
-                       wantData: TestData{},
-                       wantErr:  true,
-               },
-               {
-                       name:     "Invalid YAML content",
-                       fileName: "invalid.yaml",
-                       content:  "name: Test\nvalue: invalid_int\n",
-                       wantData: TestData{},
-                       wantErr:  true,
-               },
-       }
-
-       for _, tt := range tests {
-               t.Run(tt.name, func(t *testing.T) {
-                       // Setup: Create a temporary file with the provided content if content is not empty
-                       if tt.content != "" {
-                               err := os.WriteFile(tt.fileName, []byte(tt.content), 0644)
-                               assert.NoError(t, err)
-                               defer os.Remove(tt.fileName) // Cleanup the file after the test
-                       }
-
-                       var data TestData
-                       err := loadFromYAMLFile(tt.fileName, &data)
-
-                       if tt.wantErr {
-                               assert.Error(t, err)
-                       } else {
-                               assert.NoError(t, err)
-                               assert.Equal(t, tt.wantData, data)
-                       }
-               })
-       }
-}