- 
                Notifications
    
You must be signed in to change notification settings  - Fork 209
 
          Rename components directory to resources under .dapr directory
          #1149
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Draft
      
      
            pravinpushkar
  wants to merge
  38
  commits into
  dapr:master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
pravinpushkar:feat/resources_dir
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Draft
                    Changes from 34 commits
      Commits
    
    
            Show all changes
          
          
            38 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      bd3657f
              
                set dapr run defaults precedence
              
              
                pravinpushkar 4e6d8b5
              
                dapr init create resources dir and moves existing components content …
              
              
                pravinpushkar 8358a21
              
                modify tests
              
              
                pravinpushkar c3f41e9
              
                fix test
              
              
                pravinpushkar 6affa75
              
                fix tests
              
              
                pravinpushkar 1b421b0
              
                add tests
              
              
                pravinpushkar 0363365
              
                trigger pr checks
              
              
                pravinpushkar d9caa15
              
                Update pkg/standalone/common.go
              
              
                pravinpushkar 2007ed5
              
                Apply suggestions from code review
              
              
                pravinpushkar bf0e7ff
              
                review comments
              
              
                pravinpushkar d8422a7
              
                review comments
              
              
                pravinpushkar e73ec7d
              
                fix error handle on path not present
              
              
                pravinpushkar 093239b
              
                fix tests
              
              
                pravinpushkar 5df0795
              
                trigger pr checks
              
              
                pravinpushkar 125ebc8
              
                readme changes and some more messages today
              
              
                pravinpushkar 3b55cd5
              
                trigger pr checks
              
              
                pravinpushkar 3c8020b
              
                Update README.md
              
              
                pravinpushkar ff6ce5d
              
                update readme
              
              
                pravinpushkar 5334d15
              
                Typo
              
              
                shubham1172 57cfa8a
              
                Type (2)
              
              
                shubham1172 15a894c
              
                Merge branch 'master' into feat/resources_dir
              
              
                mukundansundar a4c5f81
              
                few more refactoring
              
              
                pravinpushkar 03d190a
              
                Merge branch 'master' into feat/resources_dir
              
              
                mukundansundar 5a624af
              
                fix review comment and failing merge
              
              
                pravinpushkar 3989aad
              
                make symlink
              
              
                pravinpushkar 0749c5c
              
                Merge branch 'master' into feat/resources_dir
              
              
                pravinpushkar 4a421d5
              
                fix tests
              
              
                pravinpushkar f73af11
              
                review comments
              
              
                pravinpushkar e7ccf04
              
                fix tests
              
              
                pravinpushkar 771b256
              
                some more refactor
              
              
                pravinpushkar c5646d4
              
                merge master and fix conflicts
              
              
                pravinpushkar 968b5ca
              
                fix tests
              
              
                pravinpushkar ed1169c
              
                change few uninstall to uninstallAll and add cleanup in upgrade test
              
              
                pravinpushkar 5871ad4
              
                Merge branch 'master' into feat/resources_dir
              
              
                mukundansundar 771d423
              
                Merge branch 'master' into feat/resources_dir
              
              
                shubham1172 e471c28
              
                fix conflicts & merge master
              
              
                pravinpushkar e2794b0
              
                Merge branch 'master' into feat/resources_dir
              
              
                pravinpushkar d605587
              
                lint fix
              
              
                pravinpushkar File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| /* | ||
| Copyright 2022 The Dapr Authors | ||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
| 
     | 
||
| package standalone | ||
| 
     | 
||
| import ( | ||
| "os" | ||
| path_filepath "path/filepath" | ||
| "testing" | ||
| 
     | 
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
| 
     | 
||
| func TestCreateSymLink(t *testing.T) { | ||
| // create a temp dir to hold the symlink and actual directory. | ||
| tempDir := createTempDir(t, "dapr-test", "") | ||
| defer cleanupTempDir(t, tempDir) | ||
| originalDir := createTempDir(t, "original_dir", tempDir) | ||
| existingSymLinkDir := createTempDir(t, "new_name_exist", tempDir) | ||
| tests := []struct { | ||
| name string | ||
| actualDirName string | ||
| symLinkName string | ||
| expectedError bool | ||
| }{ | ||
| { | ||
| name: "create symlink for resources directory", | ||
| actualDirName: originalDir, | ||
| symLinkName: path_filepath.Join(tempDir, "new_name"), | ||
| expectedError: false, | ||
| }, | ||
| { | ||
| name: "create symlink when resources directory does not exist", | ||
| actualDirName: "invalid-dir", | ||
| symLinkName: "new_name", | ||
| expectedError: true, | ||
| }, | ||
| { | ||
| name: "create symlink when symlink named directory already exists", | ||
| actualDirName: originalDir, | ||
| symLinkName: existingSymLinkDir, | ||
| expectedError: true, | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| err := createSymLink(tt.actualDirName, tt.symLinkName) | ||
| assert.Equal(t, tt.expectedError, err != nil) | ||
| }) | ||
| } | ||
| } | ||
| 
     | 
||
| func TestMoveDir(t *testing.T) { | ||
| // create a temp dir to hold the source and destination directory. | ||
| tempDir := createTempDir(t, "dapr-test", "") | ||
| defer cleanupTempDir(t, tempDir) | ||
| // create a file in the source and destination directory. | ||
| src1 := createTempDir(t, "src1", tempDir) | ||
| dest2 := createTempDir(t, "dest2", tempDir) | ||
| srcFile := createTempFile(t, src1, "pubsub.yaml") | ||
| destFile := createTempFile(t, dest2, "pubsub-dest.yaml") | ||
| tests := []struct { | ||
| name string | ||
| srcDirName string | ||
| destDirName string | ||
| expectedError bool | ||
| presentFileName string | ||
| }{ | ||
| { | ||
| name: "move directory when source directory contains files", | ||
| srcDirName: src1, | ||
| destDirName: createTempDir(t, "dest1", tempDir), | ||
| expectedError: false, | ||
| presentFileName: path_filepath.Base(srcFile), | ||
| }, | ||
| { | ||
| name: "move directory when source directory does not contain files", | ||
| srcDirName: createTempDir(t, "src2", tempDir), | ||
| destDirName: dest2, | ||
| expectedError: false, | ||
| presentFileName: path_filepath.Base(destFile), | ||
| }, | ||
| { | ||
| name: "move directory when source directory does not exists", | ||
| srcDirName: path_filepath.Join(tempDir, "non-existent-source-dir"), | ||
| destDirName: createTempDir(t, "dest3", tempDir), | ||
| expectedError: true, | ||
| }, | ||
| { | ||
| name: "move directory when destination directory does not exists", | ||
| srcDirName: createTempDir(t, "src4", tempDir), | ||
| destDirName: path_filepath.Join(tempDir, "non-existent-dir-dir"), | ||
| expectedError: true, | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| err := moveDir(tt.srcDirName, tt.destDirName) | ||
| assert.Equal(t, tt.expectedError, err != nil) | ||
| if tt.presentFileName != "" { | ||
| // check if the files are moved correctly. | ||
| assert.FileExists(t, path_filepath.Join(tt.destDirName, tt.presentFileName)) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
| 
     | 
||
| func createTempDir(t *testing.T, tempDirName, containerDir string) string { | ||
| dirName, err := os.MkdirTemp(containerDir, tempDirName) | ||
| assert.NoError(t, err) | ||
| return dirName | ||
| } | ||
| 
     | 
||
| func createTempFile(t *testing.T, tempDirName, fileName string) string { | ||
| file, err := os.CreateTemp(tempDirName, fileName) | ||
| assert.NoError(t, err) | ||
| defer file.Close() | ||
| return file.Name() | ||
| } | ||
| 
     | 
||
| func cleanupTempDir(t *testing.T, dirName string) { | ||
| err := os.RemoveAll(dirName) | ||
| assert.NoError(t, err) | ||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.